-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to safely inject delayed formatters. #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the change itself, but making 4.08 the minimum for this library seems a bit painful. @jeremiedimino wdyt?
Sorry, I missed this PR initially. This restriction was intentional. @Drup if you want easy interop with |
I don’t know about Drup, but I have a simple use case:
There’s already plenty of formatters written using Format/Formatter. It would be nice if there was an easy way to reuse them in Pp.
…On Jun 9, 2020, 7:24 AM -0700, Jérémie Dimino ***@***.***>, wrote:
Sorry, I missed this PR initially. This restriction was intentional.
@Drup if you want easy interop with Format.t, why not use Fmt? If we had this function the API, I feel like there is not much reason for Pp to exist, it becomes pretty much the same as Fmt but with a more complicated implementation.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
The library aims to provide an easy to use interface for formatting messages. The new function doesn't compromise that, it just allows users to reuse existing Personally I'm too far gone when it comes to format, so I use Also, the fact that |
I agree, but then it does open the question of the purpose of FTR, the main motivation for writing
As a result, the formatting of messages printed by Dune was very inconsistent and not great. @mshinwell also mentioned to me that such format strings can be difficult to work with, in the context of the compiler. Overall, my impression is that writing good format strings requires expert knowledge. So I considered the following options:
I opted for the last option. |
It seems to me your argument mainly concerns As far as I'm concerned, |
Also, if you are interested, I'm pretty sure I can write a function |
That seems like a good compromise, yes.
Well,
That would be nice. BTW, I feel like it would be simpler if (** [markdown s] interprets [s] as a string following format: ... *)
val markdown : string -> _ Pp.t
val markdownf : ('a, unit, 'b Pp.t) format -> 'a |
Ok, I'll simplify the patch when I have time.
The problem is that
So you want to decouple the composition aspect from the layout aspect. In spirit, this is actually what My impression is that |
Just to clarify: are you thinking of I see
Why does
It's also the DSL you have to learn just for printing, i.e. Regarding the win from a community perspective, are you thinking of debugging functions that take a format and might print nothing? |
It would be nice to get this in since I'd like to use |
Ah, yes, I forgot about this. Please feel free to take/re-propose the bits you want. :) |
Signed-off-by: Rudi Grinberg <[email protected]>
@jeremiedimino should be ready now |
Signed-off-by: Jeremie Dimino <[email protected]>
Looks good, I added a disclaimer and merged. Thanks! |
Hello @Drup I am working on preparing a release for the pp project - this will contain #17 which reverts some changes from this PR. This is motivated by #9 and the ability to serialize pps without running the risk of encountering dynamic failures. I didn't spot any use for |
From the docs:
I find that a big deal breaker, as it makes the library incompatible with
pp
functions provided by most libraries (which is ironic, given the name). It also means it's just a formatter library for error messages, not a modular pretty printing library.Fortunately, it's not that difficult to fix using the (moderatly recent)
Format.kdprintf
function, which was introduced precisely to write and transport error messages in the compiler. :)A change I didn't do was to replace
textf
.textf
is, in my opinon, a broken function which provides wrong expectation (tags and formatting are ignored, formatting decisions are taken too eagerly, etc) that should be replaced by the newPp.pf
.